/**
 * Created by zhangzhihao on 2016/12/06 11:00;
 */
var vm = new Vue({
    el: '#main',
    data: {
       	friendcheck:{},
    },
    created: function () {
    	this.init();
    },
    methods: {
    	//初始化
    	init:function(){
    		App.ajax({
    			type:"POST",
    			url:App.getApiUrl("checkfriend"),
    			success:function(data){
    				vm.friendcheck = data;
				}
    		})
    	},
    	//全选
    	allBtn:function(){
            	var flag=document.getElementById("allCheck").checked;
            	var cks=document.getElementsByName("any");
            		 for(var i=0;i<cks.length;i++){
            			 cks[i].checked=flag;
            	}
    	},
    	//删除按钮
    	deletBtn:function(){
    		var str = "";
        	var _data = {};
        	var cks=document.getElementsByName("any");
        	for(var i=0;i<cks.length;i++){
        		if(cks[i].checked == true){
        			str += $("#id"+i).val()+",";
        		}
        	};
        	_data.ids = str.substring(0,str.length-1);
        	App.ajax({
        		type:"POST",
    			url:App.getApiUrl("deletfriend"),
    			data:_data,
    			success:function(data){
    				 window.location.reload(); 
    			}
    		});
    	},
    	//查询
    	check_c:function(){
    		var _data = {};
    		var reg = /^1[3|4|5|7|8][0-9]{9}$/;
    		_data.optNo= $("#check_no").val();
    		_data.optName= $("#check_name").val();
    		_data.companyType= $("#opt_leixing").find("option:selected").val();
    		_data.optStatus= $("#opt_type").find("option:selected").val();
    		_data.applicationDate= $("#beginDay").val();
    		if($("#check_phone").val() != ""){
    			if(reg.test($("#check_phone").val()) == false){
    				parent.showAlert("请输入正确电话号码");
    				return;
    			}
    		}
			_data.phone= $("#check_phone").val();
    		App.ajax({
    			type:"POST",
    			url:App.getApiUrl("checkfriend"),
    			data:_data,
    			success:function(data){
    				window.location.reload();
				}
    		})
    	},
        //新增按钮
        addBtn:function(){
        	window.location.href = App.getBaseUrl() + "sys/task/friendadd.html";
        },
        //修改跳转
        gotoPage:function(url,id){
        	window.location.href = App.getBaseUrl() + url+"?id="+id;
        },
        //重置按钮
        check_r:function(){
            window.location.reload();
        },     
    }
});

